(()=>{function t(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,o)}return a}function e(e){for(var o=1;oMath.round(100*Number(t))/100,{storeId:n,fbPixelIds:r,fbcapiServerUri:c,blockPixel:i,PixelConversionData:u=[]}=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!t||!e)return null;const a=document.currentScript;if(a){const t=a.getAttribute(e);if(t)try{return JSON.parse(t)}catch(t){return null}}return null}("facebook-pixel","data-facebook-pixel-data")||{};let d=u.length>0&&r.length>0;const p=async t=>{let{eventName:a,payload:o={},capiParam:u={},eventID:p="",orderPayTime:l=""}=t;var s;if(await new Promise((t=>{setTimeout((()=>{if("function"==typeof s){const e=s();t(e)}else t()}),0)})),!window.fbq)return;if(p=p||(()=>{if(crypto&&crypto.randomUUID)return crypto.randomUUID();let t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){let a=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?a:3&a|8).toString(16)}))})(),i&&(shopSDK.tool.getCookie("_fbp")||"PageView"!==a)||window.fbq("track",a,o,{eventID:p}),!d)return;shopSDK.tool.getCookie("_fbp")||await pollUntilAvailable((()=>shopSDK.tool.getCookie("_fbp")));const y=e({store_id:n,event_name:a,event_time:l||Math.floor((new Date).getTime()/1e3),event_source_url:window.location.href,event_id:p,pixels:r,user_data:{fbp:shopSDK.tool.getCookie("_fbp"),fbc:shopSDK.tool.getCookie("_fbc")}},u),m=JSON.stringify(y);let _;try{_=await fetch(c,{method:"POST",headers:{"Content-Type":"text/plain"},body:m,keepalive:!0})}catch(t){let e=!1;if(navigator.sendBeacon)try{const t=new Blob([m],{type:"text/plain"});e=navigator.sendBeacon(c,t)}catch(t){e=!1}if(!e){let t=new XMLHttpRequest,e=m;t.open("POST",c,!0),t.setRequestHeader("Content-type","text/plain"),t.send(e)}}};shopSDK.register(["analytics"],(t=>{let{analytics:a}=t;const n=window.checkoutcurrency||window.checkoutCurrency||"USD",c=(t,e)=>a.event.subscribe(t,e);c("page_viewed",(async()=>{const t=a.init.context.pageType;if("error"===t)return;const e=getPageCoreData("product-page"),o="product"===t&&e;if(await p({eventName:"PageView"}),o){var r,c;const t={content_ids:[e.ID],content_type:"product",content_name:e.title,value:e.min_price,currency:n,content_category:null===(r=e.categories)||void 0===r||null===(c=r[0])||void 0===c?void 0:c.name};await p({eventName:"ViewContent",payload:t,capiParam:{custom_data:t}})}})),c("theme_search",(async t=>{const{q:e}=t.data;if(!e)return;const a={search_string:e};await p({eventName:"Search",payload:a,capiParam:{custom_data:a}})})),c("product_added_to_cart",(async t=>{var e,a;const{cartLine:r,req:c}=t.data,i={content_type:"product_group",value:o(r.price)*c.quantity,currency:n,content_ids:[r.product_id],contents:[{id:r.product_id,title:r.product.title,quantity:c.quantity,category:null===(e=r.categories)||void 0===e||null===(a=e[0])||void 0===a?void 0:a.name,item_price:o(r.price)}]};await p({eventName:"AddToCart",payload:i,capiParam:{custom_data:i}})})),c("product_batch_added_to_cart",(async t=>{const{cartLines:a,req:r}=t.data;const c=function(t,a){const o=new Map;return a.forEach((t=>{var e,a;const n="".concat(t.product_id,"-").concat(null!==(e=null===(a=t.variant)||void 0===a?void 0:a.ID)&&void 0!==e?e:"sp");o.set(n,t)})),t.product.map((t=>{var a;const n="".concat(t.product_id,"-").concat(null!==(a=t.variant_id)&&void 0!==a?a:"sp"),r=o.get(n);return r?e(e({},r),{},{quantity:t.quantity}):null})).filter(Boolean)}(r,a),i={content_type:"product_group",value:o(c.reduce(((t,e)=>t+e.quantity*e.price),0)),currency:n,content_ids:c.map((t=>t.product_id)),contents:c.map((t=>{var e,a;return{id:t.product_id,title:t.product.title,quantity:t.quantity,category:null===(e=t.categories)||void 0===e||null===(a=e[0])||void 0===a?void 0:a.name,item_price:o(t.price)}}))};await p({eventName:"AddToCart",payload:i,capiParam:{custom_data:i}})})),c("theme_initiate_checkout",(async t=>{const{items:e=[],currency:a,quantity:n,value:c}=t.data.originalPayload||{};!function(){var t;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=[];var o,n;null!==(t=window.fbq)&&void 0!==t&&t.getState&&(a=null===(o=window.fbq.getState())||void 0===o||null===(n=o.pixels)||void 0===n?void 0:n.map((t=>t.id)));const c=[];e.forEach((t=>{var e;null==t||null===(e=t.categoryIds)||void 0===e||e.forEach((t=>{c.includes(t)||c.push(t.toString())}))})),u.forEach((t=>{const{type:e,value:o,pixel_id:n}=t;"category"===e&&c.includes(o)&&!a.includes(n)&&(window.fbq("init",n),r.push(n),d=!0)}))}(e);const i={content_type:"product_group",value:o(c),currency:a,num_items:n,content_ids:e.map((t=>t.id||t.productId)),contents:e.map((t=>({id:t.id||t.productId,title:t.productTitle||t.name,quantity:t.quantity,category:t.category,item_price:o(t.price)})))};await p({eventName:"InitiateCheckout",payload:i,capiParam:{custom_data:i}})})),c("theme_add_payment_info",(async t=>{const{userData:{email:a,phone:r,first_name:c,last_name:i,country:u,state:d,city:l,postcode:s}={},items:y=[],quantity:m,value:_}=t.data,f={content_type:"product_group",value:o(_),currency:n,num_items:m,content_ids:y.map((t=>t.productId)),contents:y.map((t=>({id:t.productId,title:t.productTitle,quantity:t.quantity,category:t.category,item_price:o(t.price)})))},v=e({fbp:shopSDK.tool.getCookie("_fbp"),fbc:shopSDK.tool.getCookie("_fbc")},a&&{em:a,ph:r,fn:c,ln:i,country:u,st:d,ct:l,zp:s});await p({eventName:"AddPaymentInfo",payload:f,capiParam:{custom_data:f,user_data:v}})})),c("checkout_success",(async t=>{const{line_items:a=[],shipping_address:{email:r,phone:c,first_name:i,last_name:u,country:d,state:l,city:s,postcode:y}={},orderNumber:m,quantity:_,orderPayTime:f,value:v}=t.data,g=f?Math.floor(new Date(f).getTime()/1e3):null,h={content_type:"product_group",value:o(v),currency:n,content_ids:a.map((t=>t.productId)),num_items:_,contents:a.map((t=>({id:t.productId,title:t.name,quantity:t.quantity,category:t.category,item_price:o(t.price)})))},b=e({fbp:shopSDK.tool.getCookie("_fbp"),fbc:shopSDK.tool.getCookie("_fbc")},r&&{em:r,ph:c,fn:i,ln:u,country:d,st:l,ct:s,zp:y});await p({eventName:"Purchase",eventID:btoa(m),payload:h,orderPayTime:g,capiParam:{custom_data:h,user_data:b}})}))}))})();